from flask import Flask
from models.model import db
from views.vendor import vendor_bp
from views.good import good_bp
from views.worker import worker_bp
from views.vip import vip_bp
from views.user import user_bp

def create_app(config):
    flask_app = Flask(__name__)

    # 加载配置文件
    flask_app.config.from_object(config)

    # 初始化数据库
    db.init_app(flask_app)

    # 注册蓝图
    flask_app.register_blueprint(vendor_bp)
    flask_app.register_blueprint(good_bp)
    flask_app.register_blueprint(worker_bp)
    flask_app.register_blueprint(vip_bp)
    flask_app.register_blueprint(user_bp)
    return flask_app